<?php
require_once 'config.inc.php'; 
if (empty($_SESSION["username"])){
	header("Location:./admin/login.php?referer=". $_SERVER['REQUEST_URI']);
}
	$uid = $_SESSION["uid"];
	
if ($_GET['id']) {
	$id = intval($_GET['id']);
	$path = ','.str_pad($id,5,'0',STR_PAD_LEFT);
	

	$intShowNum = 30;

	$sql =  "SELECT count(*)  FROM {$tablepre}note as a left join {$tablepre}channel as b  on a.cid = b.id  
	WHERE a.uid='$uid' AND  b.id IN(
		SELECT id FROM {$tablepre}channel WHERE path like'%$path%'
	)";
	$intTotal = $db->result_first($sql);
	$aPageDatas =   Pager ( $intTotal , $intShowNum);
	$pagenav = show_pagenav($aPageDatas);
	$limit ="LIMIT $aPageDatas[offset],$intShowNum";
	
	$sql = "SELECT a.*,b.name  FROM {$tablepre}note as a left join {$tablepre}channel as b  on a.cid = b.id  
	WHERE a.uid='$uid' AND  b.id IN(
		SELECT id FROM {$tablepre}channel WHERE path like'%$path%'
	)	
	$order_by_sql $limit ";

	$pinfos = $db->fetch_all($sql);
	//pecho($pinfos);
		
	//$sql = "SELECT * FROM {$tablepre}note WHERE id = $id ";
	
}

$nav = get_nav($id);
$_var['pagenav']=$pagenav;

?>
<link rel="stylesheet" type="text/css" href="images/style.css">
<link rel="stylesheet" type="text/css" href="images/note.css">

<div id="nav">
	<div class="left">分类：<?php echo $nav ?></div>
	<div class="right"><a href="/admin/admin_channel.php?id=<?=$id?>">[编辑]</a></div>
</div>

<div id="channel">
<dl class=notes>
		<dt><strong>文章列表</strong> </dt>
		<?php 
		 foreach( $pinfos as $note ) {?>
		 <dd><a title="" href="view_note.php?id=<?php echo $note[id] ?>"><?php echo  $note[title] ?>:<?php echo  $note[hit] ?></a></a><em>[<?php echo  $note[name] ?>] <?php echo format_date('m/d/y H:i','',$note[update_time])  ?></em></dd>
		 <?php  } ?>
		 </dl>
 </div>
 <div class="pages"><?=$_var['pagenav']?></div>  
<?
require_once 'foot.inc.php';
?>